import 'package:du_application/provide/EvaluateProvider.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provide/provide.dart';

class Evaluate extends StatelessWidget {
  final int id;
  const Evaluate({Key key,this.id}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    ScrollController scrollController=ScrollController();
    return Provide<EvaluateProvider>(
      builder: (context, child, index) {
        index.getEvaluate(context,id);
     return Scaffold(
      appBar: AppBar(
        title:Text("评价列表")
      ),
      body:Container(
      child: ListView(
        controller: scrollController,
        children: <Widget>[
          Container(
            color: Colors.white,
          child: Row(
           children:[
             Container(
                padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40),vertical:ScreenUtil().setWidth(20) ),
               child:Text("购买评价",style: TextStyle(
                 fontWeight:FontWeight.bold,fontSize:ScreenUtil().setSp(40)
               ),)
             ),
             Container(
               child:Text("${index.evaluateModel.data.count!=null?index.evaluateModel.data.count/index.evaluateModel.data.yes*100.0:0}%的人觉得很赞",style: TextStyle(
                 color: Colors.grey
               ))
             ),
           ]
          ),
          ),
             Container(
                  child: Container(
                    padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40),vertical:ScreenUtil().setWidth(20) ),
                    // margin: EdgeInsets.only(top: 5),
                 
                    color: Colors.white,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                Container(
                   
                  child: Text("尺码感受",
                      style: TextStyle(
                                 fontWeight:FontWeight.bold,fontSize:ScreenUtil().setSp(40)
                               ),)
                ),
                        Row(
                          children: <Widget>[
                            Text("${index.evaluateModel.data.count!=null?index.evaluateModel.data.count/index.evaluateModel.data.yes*100.0:0}%的人感觉很赞",
                                style: TextStyle(
                                    color: Colors.grey[600], fontSize: 12)),
                          ],
                        ),
                      ],
                    ),
                  ),
                ),
                Container(
                   padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40),vertical:ScreenUtil().setWidth(20) ),
                  color: Colors.white,
                  margin: EdgeInsets.only(bottom: 5),
           
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                   
                    Container(padding: EdgeInsets.symmetric(
                                            horizontal: 10, vertical: 5),
                                        child: Text(
                                          "合适（${index.evaluateModel.data.yes!=null?index.evaluateModel.data.yes:""}）",
                                          style: TextStyle(color: Colors.white),
                                        ),
                                        decoration: BoxDecoration(
                                          color: Colors.grey,
                                          borderRadius: BorderRadius.all(
                                              Radius.circular(3)),
                                          // border: Border.all(width:1,color:Colors.grey),
                                        ),
                         ),
                    Container(padding: EdgeInsets.symmetric(
                                            horizontal: 10, vertical: 5),
                                        child: Text(
                                          "偏大（${index.evaluateModel.data.big!=null?index.evaluateModel.data.big:""}）",
                                          style: TextStyle(color: Colors.white),
                                        ),
                                        decoration: BoxDecoration(
                                          color: Colors.grey,
                                          borderRadius: BorderRadius.all(
                                              Radius.circular(3)),
                                          // border: Border.all(width:1,color:Colors.grey),
                                        ),
                         ),
                    Container(padding: EdgeInsets.symmetric(
                                            horizontal: 10, vertical: 5),
                                        child: Text(
                                          "偏小（${index.evaluateModel.data.small!=null?index.evaluateModel.data.small:""}）",
                                          style: TextStyle(color: Colors.white),
                                        ),
                                        decoration: BoxDecoration(
                                          color: Colors.grey,
                                          borderRadius: BorderRadius.all(
                                              Radius.circular(3)),
                                          // border: Border.all(width:1,color:Colors.grey),
                                        ),
                         ),
                    
                    ],
                  ),
                ),
            ListView(
                shrinkWrap: true,
                 controller: scrollController,
              children:index.evaluateModel.data.commentList!=null?index.evaluateModel.data.commentList.map((item){
                  return  Card(
              child: Container(
                padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(10),vertical:ScreenUtil().setWidth(20) ),
              child: Row(children: [
            Container(
                margin: EdgeInsets.all(ScreenUtil().setWidth(10)),
            
                child: CircleAvatar(
                  backgroundImage:
                      NetworkImage(item.userInfo.avatarUrl),
                )),
         Container(
           width: ScreenUtil().setWidth(800),
           child: Column(
             crossAxisAlignment: CrossAxisAlignment.start,
             children: [
          Container(
           margin: EdgeInsets.only(bottom:ScreenUtil().setWidth(10)),
            child: Row(children: [
              Container(child: Text(item.userInfo.nickName)),
              Container(
                margin: EdgeInsets.only(left:ScreenUtil().setWidth(10)),
                padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(10),vertical:ScreenUtil().setWidth(5) ),
                child: Text(item.size==1?"很赞":item.size==2?"偏大":"偏小"),
                decoration:BoxDecoration(
                border:Border.all(color:Colors.black,width:ScreenUtil().setSp(1))
                ),
                )
            ])
          ),
            Container(
                     margin: EdgeInsets.only(left:ScreenUtil().setWidth(10)),
              child: Text(item.addTime.split(" ")[0],style: TextStyle(
                color:Colors.grey[400]
              ),),
            ),
            Container(
              padding: EdgeInsets.symmetric(vertical:ScreenUtil().setWidth(20)),
                 margin: EdgeInsets.only(left:ScreenUtil().setWidth(10)),
              child: Text(item.content,style: TextStyle(
                color:Colors.grey[400]
              ),),
            ),
             
           ])
         )
          ])));
              }).toList():[],
            )
        ],
      ),
    )
    );
 }); 
  }
}
